package InputStream;

import org.junit.jupiter.api.Test;

import java.io.*;

public class ObjectInputStreamTest {

    @Test
    public void test() throws IOException, ClassNotFoundException {
        String filePath = "D:\\aaaa\\data.dat";
        FileInputStream fileInputStream = new FileInputStream(filePath);
        ObjectInputStream objectInputStream = new ObjectInputStream(fileInputStream);

        //反序列化读取序列化的文件，读取顺序一定要和序列化的顺序一致
        System.out.println(objectInputStream.readInt());
        System.out.println(objectInputStream.readBoolean());
        System.out.println(objectInputStream.readChar());
        System.out.println(objectInputStream.readDouble());
        System.out.println(objectInputStream.readUTF());
        System.out.println(objectInputStream.readObject());

        //关闭流
        objectInputStream.close();


    }
}

